package com.pda.xinma.ui.order;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.pda.xinma.R;
import com.pda.xinma.adapter.OrderDetailAdapter;
import com.pda.xinma.bean.OrderBean;
import com.pda.xinma.contract.OrderDetailContract;
import com.pda.xinma.presenter.OrderDetailPresenter;
import com.wangshen.base.app.AppActivityKey;
import com.wangshen.base.ui.mvp.base.ui.BaseMvpActivity;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = AppActivityKey.ORDERDETAILACTIVITY)
public class OrderDetailActivity extends BaseMvpActivity<OrderDetailPresenter> implements OrderDetailContract.View {
    @BindView(R.id.iv_close)
    ImageView ivClose;
    @BindView(R.id.tv_back)
    TextView tvBack;
    @BindView(R.id.tv_container)
    TextView tvContainer;
    @BindView(R.id.tv_articleId)
    TextView tvArticleId;
    @BindView(R.id.tv_model)
    TextView tvModel;
    @BindView(R.id.tv_grade)
    TextView tvGrade;
    @BindView(R.id.tv_planNum)
    TextView tvPlanNum;
    @BindView(R.id.tv_startTime)
    TextView tvStartTime;
    @BindView(R.id.rv_content)
    RecyclerView rvContent;
    OrderDetailAdapter orderDetailAdapter;
    @Override
    public OrderDetailPresenter getPresenter() {
        return new OrderDetailPresenter();
    }

    @Override
    public int getView() {
        return R.layout.activity_order_detail;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {
        String order=getIntent().getExtras().getString("order");
        tvContainer.setText(order);
        presenter.getOrderByNo(order);
    }

    @Override
    public void setData(OrderBean orderBean) {
        tvArticleId.setText(orderBean.getArticleId());
        tvGrade.setText(orderBean.getGrade());
        tvModel.setText(orderBean.getModel());
        tvPlanNum.setText(orderBean.getPlanNum()+"");
        tvStartTime.setText(orderBean.getStartTime());
        orderDetailAdapter=new OrderDetailAdapter(R.layout.item_order_detail,orderBean.getProcessInfos());
        rvContent.setAdapter(orderDetailAdapter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.iv_close, R.id.tv_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_close:
                finishActivity();
                break;

        }
    }
}
